package com.sc.nft.entity.vo.ecology;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.sc.nft.enums.UserEcologyExpenditureTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class EcologyPointsExpenditureRecordVO {

    @ApiModelProperty(value = "类型 ECOLOGY_POINTS:生态燃料 EQUITY_PROPS:权益道具")
    private UserEcologyExpenditureTypeEnum type;

    @ApiModelProperty(value = "名称")
    private String typeName;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "奖励名称")
    private String linkName;

    @ApiModelProperty(value = "奖励数量")
    private String linkCount;

    @ApiModelProperty(value = "奖励图片")
    private String linkImage;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    public void setLinkCount(BigDecimal linkCount) {
        if(type == UserEcologyExpenditureTypeEnum.ECOLOGY_POINTS){
            this.linkCount = linkCount.setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
        }else if(type == UserEcologyExpenditureTypeEnum.EQUITY_PROPS){
            this.linkCount = linkCount.stripTrailingZeros().toPlainString();
        }
    }
}
